//543
import BTree from "./index.js";
function diameterBTree(root) {
  let maxLength = 0;
  function travel(root) {
    if (root === null) {
      return 0;
    }
    const leftLength = travel(root.left) + 1;
    const rightLength = travel(root.right) + 1;
    if (leftLength + rightLength > maxLength)
      maxLength = leftLength + rightLength;
    return Math.max(leftLength, rightLength);
  }
  travel(root);
  return maxLength;
}

const root = new BTree();
diameterBTree(root);
